#include "InputHandler.h"
#include "Simulation.h"
#include "EngineManager.h"

#include "Ogre.h"
 
#include "OgreWindowEventUtilities.h"
 
#ifdef WIN32
#include "windows.h" 
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
#else
int main (int argc, char *argv[]) {
#endif 
	OgreEngineManager &EngineManager = OgreEngineManager::Instance();
	if(EngineManager.Startup())
		EngineManager.CreateScene();
	else
	{
		EngineManager.Shutdown();
		return 0;
	}
	
	while (EngineManager.GetState() != SIM_SHUTDOWN)
	{
        EngineManager.GetInput()->capture();
		
        // run the message pump (Eihort)
		Ogre::WindowEventUtilities::messagePump();
		
		EngineManager.GetRoot()->renderOneFrame();
    }
 
    // clean up after ourselves
	EngineManager.Shutdown();
 
    return 0;
}